$(function(){
//nav效果
	$("#nav li:eq(0)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#beauty").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
	}).mouseleave(function(){
		$("#beauty").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	$("#nav li:eq(1)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#milk").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
	}).mouseleave(function(){
		$("#milk").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	$("#nav li:eq(2)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#tax").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
	}).mouseleave(function(){
		$("#tax").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	$("#nav li:eq(3)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#overseas").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
	}).mouseleave(function(){
		$("#overseas").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	
//nav 搜索框
   	$("#nav .text").focus(function(){
   		$(this).animate({"width":"168"},1000);
   	}).blur(function(){
   		$(this).animate({"width":"134"},1000);
   	});
   	
   	var 
   		onOff=true;
   	$(".all_sel").click(function(){
   		if(onOff){
   			$(".btn_sel").attr("checked",true);
   		}else{
   			$(".btn_sel").attr("checked",false);
   		}
   		onOff=!onOff;
   	});
   	
   	$(".btn_sel").click(function(){
   		if(onOff){
   			$(".all_sel").children().attr("checked",true);
   		}else{
   			$(".all_sel").children().attr("checked",false);
   		}
   		onOff=!onOff;
   	});
   	
   	$(".total_end").text(getCookie("price"));
   	$(".num").text(getCookie("num"));
   
   function getCookie(key){
		var str=document.cookie;
		var arr=str.split("; ");
		for(var i=0;i<arr.length;i++){
			var newArr=arr[i].split("=");
			if(newArr[0]==key){
				return decodeURI(newArr[1]);
			}
		};
	}
   	
});